package leetcode.biweekly.week95;

import java.util.LinkedList;
import java.util.Queue;

public class DataStream {

	int value, k;

	int id;

	Queue<Integer> queue;

	public DataStream(int value, int k) {
		this.value = value;
		this.k = k;
		this.id = 0;
		queue = new LinkedList<>();
	}

	public boolean consec(int num) {
		id++;
		if (num != value) {
			queue.add(id);
		}
		if (id < k) {
			return false;
		}
		while (!queue.isEmpty() && queue.peek() <= id - k) {
			queue.poll();
		}
		return queue.isEmpty();
	}
}
